﻿using System;
using FluentDBC;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            RegisterInstances();

            var app = new ShoppingApplication();
            Console.Write(app.ProcessingInvoiceForAllCustomers());
            Console.ReadKey();
        }

        static void RegisterInstances()
        {
            Container.RegisterInstance(typeof(ICustomerRepository), typeof(StubCustomerRepository));
            Container.RegisterInstance(typeof(ICustomerService), typeof(CustomerService));
            Container.RegisterInstance(typeof(ITaxStrategy), typeof(DefaultTaxStrategy));

            var obj = FluentDBCConfiguration.GetInstance()
                        .WithClass<ShoppingApplication>()
                            .Field(x => x.CustomerRepository)
                                .PreCondition()
                                .IsNotNull("CustomerRepository is null!")
                            .Field(x => x.CustomerService)
                                .PreCondition()
                                .IsNotNull("CustomerService is null!")
                            .Field(x => x.TaxStrategy)
                                .PreCondition()
                                .IsNotNull("TaxStrategy is null!")
                            .Completed();

            Container.RegisterInstance(typeof(IFluentDBCConfiguration), obj);
        }
    }
}